﻿using HCMS.CommonDtos;
using HCMS.Entities.Manage;
using HCMS.IRepositories.Manage;
using HCMS.IServices.Manage;
using HCMS.Repositories.Manage;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace HCMS.Services.Manage
{
    /// <summary>
    /// 管理 角色 应用服务
    /// </summary>
    public class RoleAppService : CommonAppService<ManageDbContext, Role>, IRoleAppService
    {
        private readonly IRepository<Role> baseRoleRepository;
        private readonly IRoleRepository roleRepository;

        public RoleAppService(
            IRepository<Role> baseRoleRepository,
            IRoleRepository roleRepository
            ) : base(baseRoleRepository)
        {
            this.baseRoleRepository = baseRoleRepository;
            this.roleRepository = roleRepository;
        }

        /// <summary>
        /// 管理 列表
        /// </summary>
        /// <param name="searchArgs">搜索 参数</param>
        /// <param name="pager">分页 参数</param>
        /// <returns></returns>
        public async Task<ListPagerDto<Role>> ManageList(SearchArgsDto searchArgs, PagerArgsDto pager)
        {
            var result = await roleRepository.ManageList(searchArgs, pager);
            return result;
        }

        /// <summary>
        /// 角色 树
        /// </summary>
        /// <returns></returns>
        public async Task<object> GetAllTree()
        {
            return await roleRepository.GetAllTree();
        }
    }
}
